/* =============================================================================
 * counterfactual
 * ===========================================================================*/

/*******************************************************************************
hypothetical cohort effect
*******************************************************************************/
clear
set obs 14
gen plot_coh = 1950 + (_n - 1)*5
merge m:1 plot_coh using "temp\cn_coh_profile.dta"
drop if _merge == 2
drop _merge
rename profile_coh_cn profile_coh

local ggc = 1.4/100 / 7			
* 1.4% = 1.87^(1/45) - 1
forvalues y = 1/7{
	replace profile_coh = profile_coh[_n-1]*(1+`ggc'*(7-`y'))^7  if plot_coh == 1980 + 5*`y'
}

save "temp\cn_coh_profile_hyp.dta", replace


/*******************************************************************************
hypothetical time effect
*******************************************************************************/
clear
set obs 31
gen plot_year = 2009 + _n
merge m:1 plot_year using "temp\cn_year_profile.dta"
drop if _merge == 2
drop _merge
rename profile_year_cn profile_year

local ggy = 4.8/100 / 28
* 4.8% = 3.38^(1/26) - 1
forvalues y = 1/28{
	replace profile_year = profile_year[_n-1]*(1+`ggy'*(28-`y'))  if plot_year == 2012 + `y'
}

save "temp\cn_year_profile_hyp.dta", replace



/*******************************************************************************
hypothetical data set
*******************************************************************************/
clear
set obs 6
gen plot_year = 2010 + (_n-1)*5
expand 8
bys plot_year: gen plot_wexp = (_n-1)*5
gen age = 20 + plot_wexp
gen plot_coh = plot_year - age

merge m:1 plot_coh using "temp\cn_coh_profile_hyp.dta"
drop if _merge == 2
drop _merge

merge m:1 plot_year using "temp\cn_year_profile_hyp.dta"
drop if _merge == 2
drop _merge

merge m:1 plot_wexp using "temp\cn_exp_profile.dta"
drop _merge

gen pred_earn = profile_coh * profile_year * profile_wexp

rename plot_year year
replace age = age + 2

sort year age
gen pred = pred_earn/pred_earn[1]

twoway (connect pred age if year == 2010, msymbol(o) color(blue) lpattern(shortdash))	///
	(connect pred age if year == 2015, msymbol(o) color(red) lpattern(longdash))		///
	(connect pred age if year == 2020, msymbol(o) color(green)),		///
	xlabel(25(5)60, labsize(medlarge))  ylabel(1(0.6)3.4, labsize(medlarge)) ///
	ytitle("Earnings", size(large))	xtitle("Age", size(large))		///
	legend(order(1 "2010" 2 "2015" 3 "2020") rows(1) pos(6) size(medlarge))			///
	name(left, replace)		
	

	
twoway (connect pred age if year == 2025, msymbol(o) color(blue) lpattern(shortdash))	///
	(connect pred age if year == 2030, msymbol(o) color(red) lpattern(longdash))		///
	(connect pred age if year == 2035, msymbol(o) color(green)),		/// 
	xlabel(25(5)60, labsize(medlarge))  ylabel(, labsize(medlarge)) ///
	ytitle("Earnings", size(large))	xtitle("Age", size(large))		///
	legend(order(1 "2025" 2 "2030" 3 "2035") rows(1) pos(6) size(medlarge))		///
	name(right, replace)
	
graph combine left right, xsize(16) ysize(8)

graph export "figures\new_normal.pdf", as(pdf) replace	
	








